package com.bearo.sharding.main;

import com.bearo.sharding.po.OrderPO;
import com.bearo.sharding.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Random;

public class App {

    private static Logger logger = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("server-config/applicationContext.xml");

//        Long orderId = Long.parseLong(String.valueOf(new Random().nextInt(9999)));

        Long orderId = 13L;

        Integer userId = new Random().nextInt(9999);


        logger.info(", orderId: {}, userId: {}", orderId, userId);

        OrderPO pass = OrderPO.builder().orderId(orderId).userId(userId).status("pass").build();
        OrderService orderService = ctx.getBean(OrderService.class);
        orderService.insert(pass);

    }

}
